<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>上传点云</title>
    <link th:href="@{/layui/css/layui.css}" rel="stylesheet"/>
    <!--<link th:href="@{/bootstrap/css/bootstrap-theme.min.css}" rel="stylesheet"/>-->
    <script th:src="@{/js/jquery-3.3.1.js}" type="text/javascript"></script>
    <!--<script th:src="@{/bootstrap/js/bootstrap.min.js}" type="text/javascript"></script>-->
</head>
<body>


<input type="text" class="form-control" placeholder="点云oss存储名称" required="required" name="saveName" id="saveName"/>
<!--<input type="text" class="form-control" placeholder="点云url名称" required="required" name="urlName" id="urlName"/>-->
<input type="text" class="form-control" placeholder="项目名" required="required" name="projectName" id="projectName"/>

<button type="button" class="layui-btn" id="test1">
    <i class="layui-icon">&#xe67c;</i>选择点云txt
</button>

<button type="button" class="layui-btn" id="test2">
    <i class="layui-icon">&#xe67c;</i>上传点云
</button>
<script th:src="@{/layui/layui.js}"></script>

<script th:inline="javascript">
    var ctx = [[@{/}]];
    layui.use('upload', function () {
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#test1', //绑定元素
            url: ctx+'upload/', //上传接口
            accept: 'file',
            auto: false,//选择文件后不自动上传
            bindAction: '#test2', //指向一个按钮触发上传
            data: {
                saveName: function () {
                    return $('#saveName').val();
                },
                projectName: function () {
                    return $('#projectName').val();
                }
                // urlName: function () {
                //     return $('#urlName').val();
                // }

            },
            before: function () {
                //上传前回调
                layer.load();
            },

            done: function (res) {
                //上传完毕回调
                console.log(res);
                layer.alert(res.msg);
                layer.closeAll('loading'); //关闭loading
            },
            error: function () {
                //请求异常回调

                layer.alert("请求失败");
                layer.closeAll('loading'); //关闭loading
            }
        });
    });
</script>
</body>
</html>